﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public static class CheckOutCommand
    {
        public static void Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (UIContext.Current.CurrentSelectedNode != null)
            {
                ObservableCollection<SolutionTreeViewNode> nodeList = new ObservableCollection<SolutionTreeViewNode>();
                nodeList.Add(UIContext.Current.CurrentSelectedNode);
                CheckOutWindow window = new CheckOutWindow(nodeList);
                window.ShowDialog();
            }
        }
        public static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (UIContext.Current.CurrentSelectedNode != null && (UIContext.Current.CurrentSelectedNode.NodeStatus == NodeStatus.CheckIn || UIContext.Current.CurrentSelectedNode.NodeStatus == NodeStatus.OthersLocked))
            {
                e.CanExecute = true;
            }
            else
            {
                e.CanExecute = false;
            }
        }
    }
}
